home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / diverses / cexpress / graphic / grabbox.asm < prev    next >
Encoding:
Assembly Source File  |  1989-05-03  |  2.6 KB  |  94 lines

  1. ;void  grab_box(box,top_x,top_y,width,depth,color);
  2. ;  unsigned char  *box,top_x,top_y,width,depth,color;
  3.  
  4.     EXTRN  _memory_model:byte
  5.     EXTRN  _video_buffer:word
  6.     EXTRN  _snow_protect:byte
  7.  
  8. _TEXT    SEGMENT BYTE PUBLIC 'CODE'
  9.     ASSUME CS:_TEXT
  10.     PUBLIC _grab_box
  11. _grab_box proc near
  12.     push bp            ;
  13.     mov  bp,sp        ;set stack frame
  14.     push di            ;
  15.     push si            ;
  16.     cmp  _memory_model,0    ;near or far?
  17.     jle  begin        ;jump if near
  18.     inc  bp            ;else add 2 to BP
  19.     inc  bp            ;
  20. begin:    push ds            ;
  21.     mov  bl,_snow_protect    ;grab _snow_protect
  22.     cmp  _memory_model,2    ;data near or far?
  23.     jb   L0            ;jump if near
  24.     les  di,dword ptr[bp+4] ;ES:DI pts to byte array
  25.     add  bp,2        ;inc BP since dword ptr
  26.     jmp  short L00        ;jump ahead
  27. L0:    mov  ax,ds        ;shift DS to ES
  28.     mov  es,ax        ;    
  29.     mov  di,[bp+4]        ;NEAR case
  30. L00:    mov  ax,_video_buffer    ;fetch video address
  31.     mov  ds,ax        ;DS points to buffer
  32.     sub  ax,ax        ;
  33.     mov  al,[bp+8]        ;row in AX
  34.     dec  ax            ;count rows from 0
  35.     mov  dl,160        ;160 bytes per row
  36.     mul  dl            ;AX times 160
  37.     sub  dx,dx        ;
  38.     mov  dl,[bp+6]        ;col in DX
  39.     dec  dx            ;count cols from 0
  40.     shl  dx,1        ;double for attributes
  41.     add  ax,dx        ;offset of topleft corner
  42.     mov  dh,[bp+10]        ;width in DH
  43.     mov  dl,[bp+12]        ;depth in DL
  44.     mov  ch,[bp+14]        ;fill attribute
  45.     mov  cl,32        ;space char for fill
  46.     mov  bp,ax        ;scrn ptr copy in BP
  47.     mov  ah,bl        ;move _snow_protect
  48.     mov  bx,cx        ;copy in BX
  49.     sub  cx,cx        ;clear loop counter
  50.     cld            ;set direction flag
  51. L1:    mov  si,bp        ;set DS:SI scrn ptr
  52.     mov  cl,dh        ;count box width
  53.     push dx            ;save width,depth ctr
  54. L2:    cmp  ah,0        ;protect against snow?
  55.     je   L7            ;jump ahead if not
  56.     mov  dx,3dah        ;status byte port addr
  57. L3:    in   al,dx        ;get status byte
  58.     test al,1        ;test bit
  59.     jnz  L3            ;loop till 0
  60.     cli            ;disable interrupts
  61. L4:    in   al,dx        ;get status byte
  62.     test al,1        ;test bit
  63.     jz   L4            ;loop till 1
  64.     movsw            ;transfer word to buffer
  65.     sub  si,2        ;pull back screen ptr
  66. L5:    in   al,dx        ;get status byte
  67.     test al,1        ;test bit
  68.     jnz  L5            ;loop till 0
  69. L6:    in   al,dx        ;get status byte
  70.     test al,1        ;test bit
  71.     jz   L6            ;loop till 1
  72.     mov  [si],bx        ;clear cell on screen
  73.     add  si,2        ;move scrn ptr back
  74.     jmp  short L8        ;jump ahead
  75. L7:    movsw            ;monochrome: transf char
  76.     mov  [si-2],bx        ;clear screen cell
  77. L8:    loop L2            ;go do next
  78.     pop  dx            ;restore width,depth ctrs
  79.     add  bp,160        ;forward ptr to next row
  80.     dec  dl            ;dec depth counter
  81.     jnz  L1            ;loop if another line
  82. L9:    sti            ;reenable interrupts
  83.     pop  ds            ;
  84.     pop  si            ;
  85.     pop  di            ;
  86.     pop  bp            ;
  87.     cmp  _memory_model,0    ;quit
  88.     jle  quit        ;
  89.     db   0CBh        ;RET far
  90. quit:    ret            ;RET near
  91. _grab_box endp
  92. _TEXT    ENDS
  93.     END
  94.